﻿package mortal.game.net.command.copy.guildCopy
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Public.*;
    import com.gengine.debug.*;
    import extend.language.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.game.view.copy.guildCopy.*;
    import mortal.mvc.core.*;

    public class GuildCopyCommand extends BroadCastCall
    {

        public function GuildCopyCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_3:SPublicInt = null;
            var _loc_4:SGuildBossRewardInfo = null;
            var _loc_5:SGuildBossRewardInfo = null;
            var _loc_6:SPlayerItem = null;
            var _loc_7:SPlayerItem = null;
            var _loc_8:SPublicInt = null;
            var _loc_9:int = 0;
            var _loc_10:int = 0;
            super.call(param1);
            var _loc_2:* = _cache.copy.guildCopy;
            switch(param1.messageHead.command)
            {
                case EPublicCommand._ECmdPublicGuildBossOpen:
                {
                    Log.debug("公会BOSS推送消息:" + "副本开启");
                    _loc_2.isOpen = true;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyOpen, null);
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossClose:
                {
                    Log.debug("公会BOSS推送消息:" + "副本关闭");
                    _loc_2.isOpen = false;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyClose, null);
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossRefreshBossTime:
                {
                    _loc_3 = param1.messageBase as SPublicInt;
                    MsgManager.showRollRadioMsg(Language.getStringByParam(20500, _loc_3.publicInt), 1, 2);
                    Log.debug("公会BOSS推送消息:" + "下一个BOSS将在" + _loc_3.publicInt + "秒后出现，请做好准备");
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossHurtList:
                {
                    _loc_2.hurtInfo = null;
                    _loc_2.hurtInfo = param1.messageBase as SGuildBossCopyHurtInfo;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyHurtUpdate, null);
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossReward:
                {
                    _loc_2.rewardInfo = param1.messageBase as SGuildBossRewardInfo;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyRewardUpdate, null);
                    Log.debug("公会BOSS推送消息:" + EPublicCommand._ECmdPublicGuildBossReward + "副本奖励开始");
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossEndRewardToClient:
                {
                    _loc_4 = param1.messageBase as SGuildBossRewardInfo;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyRewardEnd, _loc_4);
                    Log.debug("公会BOSS推送消息:" + EPublicCommand._ECmdPublicGuildBossEndRewardToClient + "副本结算");
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossRewardAdd:
                {
                    _loc_5 = param1.messageBase as SGuildBossRewardInfo;
                    _loc_2.rewardInfo.contribution = _loc_5.contribution;
                    _loc_2.rewardInfo.resource = _loc_5.resource;
                    _loc_9 = 0;
                    while (_loc_9 < _loc_5.items.length)
                    {
                        
                        _loc_6 = _loc_5.items[_loc_9];
                        _loc_10 = 0;
                        while (_loc_10 < _loc_2.rewardInfo.items.length)
                        {
                            
                            _loc_7 = _loc_2.rewardInfo.items[_loc_10];
                            if (_loc_7.itemCode == _loc_6.itemCode)
                            {
                                _loc_7.itemAmount = _loc_7.itemAmount + _loc_6.itemAmount;
                                break;
                            }
                            _loc_10++;
                        }
                        _loc_2.rewardInfo.items.push(_loc_6);
                        _loc_9++;
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyRewardUpdate, null);
                    break;
                }
                case EPublicCommand._ECmdPublicGuildBossCopyTime:
                {
                    _loc_8 = param1.messageBase as SPublicInt;
                    _loc_2.copeyLeftTime = _loc_8.publicInt;
                    NetDispatcher.dispatchCmd(ServerCommand.GuildCopyLeftTimeUpdate, null);
                    Log.debug("公会BOSS推送消息:" + EPublicCommand._ECmdPublicGuildBossCopyTime + "副本剩余" + _loc_8.publicInt + "秒");
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
